package com.book.controller;


import com.book.pojo.MonthlyRanking;
import com.book.result.Result;
import com.book.service.MonthlyRankingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cxy
 * @since 2023-10-14 09:16:33
 */
@RestController
@RequestMapping("/monthly-ranking")
public class MonthlyRankingController {

    @Autowired
    private MonthlyRankingService monthlyRankingService;

    @GetMapping("monthlyRanking")
    public Result monthlyRanking(){
        List<MonthlyRanking> list=monthlyRankingService.monthlyRanking();
        return Result.OK().setData(list);
    }

    @DeleteMapping("deleteByBookId")
    public void deleteByBookId(@RequestParam Long bookid){
        monthlyRankingService.deleteByBookId(bookid);
    }

    @PostMapping("addMonthlyRanking")
    public void addMonthlyRanking(@RequestBody MonthlyRanking monthlyRanking){
        monthlyRankingService.addMonthlyRanking(monthlyRanking);
    }

}
